#include <bits/stdc++.h>

using namespace std;
int n,s,a,b,cnt=0;
struct Apple{
    int x,y;
}apple[5010];
bool cmps(struct Apple &a,struct Apple &b){
        if(a.y!=b.y)
        {
            return a.y<b.y;
        }else{
            return a.x<b.x;
        }
}
int main()
{
    cin>>n>>s>>a>>b;
    int h = a+b;
    for(int i=0;i<n;i++){
        cin>>apple[i].x;
        cin>>apple[i].y;
    }
    sort(apple,apple+n,cmps);
    for(int i=0;i<n;i++){
        if(s-apple[i].y>=0&&apple[i].x<=h){
            cnt++;
            s-=apple[i].y;
        }
    }
    cout<<cnt;
    return 0;
}
